package cn.ch.train.${module}.controller;

import cn.ch.train.common.context.LoginMemberContext;
import cn.ch.train.common.response.CommonResponse;
import cn.ch.train.common.response.PageResult;
import cn.ch.train.${module}.request.${Domain}QueryParam;
import cn.ch.train.${module}.request.${Domain}SaveParam;
import cn.ch.train.${module}.response.${Domain}QueryResult;
import cn.ch.train.${module}.service.${Domain}Service;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/${do_main}")
public class ${Domain}Controller {
    @Autowired
    private ${Domain}Service ${domain}Service;

    @PostMapping("/save")
    public CommonResponse save(@Valid @RequestBody ${Domain}SaveParam param) {
        ${domain}Service.save(param);
        return new CommonResponse<>();
    }

    @GetMapping("/query-list")
    public CommonResponse<PageResult<${Domain}QueryResult>> queryList(@Valid ${Domain}QueryParam param) {
        PageResult<${Domain}QueryResult> ${domain}List = ${domain}Service.queryList(param);
        return new CommonResponse<>(${domain}List);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResponse delete(@PathVariable Long id) {
        ${domain}Service.delete(id);
        return new CommonResponse<>();
    }

}
